CC=g++
CFLAGS=-c -Wall
LDFLAGS= -lpthread
SOURCEDIR=source
INCLUDEDIR=include
BINDIR=bin
OBJDIR=objects


SOURCES := $(wildcard $(SOURCEDIR)/*.cpp)
OBJECTS := $(patsubst $(SOURCEDIR)/%.cpp,$(OBJDIR)/%.o,$(SOURCES))
INCLUDS	:= $(wildcard $(INCLUDEDIR)/*.h)

EXECUTABLE=$(BINDIR)/WebServer

all: $(SOURCES)	$(EXECUTABLE)
	
$(EXECUTABLE):$(OBJECTS)
	$(CC) $(LDFLAGS) $(OBJECTS) -o $@
#	rm clean

$(OBJDIR)/%.o:	$(SOURCEDIR)/%.cpp	$(INCLUDEDIR)/%.h
	$(CC) $(CFLAGS) -I$(INCLUDEDIR) $< -o $@

#$(OBJDIR)%.o:	%.cpp
#	$(CC) $(CFLAGS) -I$(INCLUDE) $< -o $@
	
clean:	
	rm -f $(EXECUTABLE)
	rm -f $(OBJECTS)
#	touch clean
	
run:	$(EXECUTABLE)
	$(EXECUTABLE)

